# @Time: 2022/9/1
# @Author: HeYuanqing
from datetime import datetime

import requests
import time
import json

import FastModelAPI


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


if __name__ == '__main__':

    # 服务测试
    # NODE_IPs = ["223.2.39.61"]
    # FastModelAPI.register(NODE_IPs)
    # FastModelAPI.initialize_model("Multiply_numbers")
    #
    # file_list = [
    #     {"file_name": "num1.txt", "file_path": "num1.txt"},
    #     {"file_name": "num3.txt", "file_path": "num3.txt"}
    # ]
    #
    # FastModelAPI.upload_model_files(file_list)
    # # 4.调用模型
    # params = {
    #     "number1": "num1.txt",
    #     "number2": 4
    # }
    # result = FastModelAPI.run_model(params)
    # if result == "success":
    #     print(f"模型调用结果: {result}")
    #     # 5.下载模型结果
    #     FastModelAPI.download_results()

    # 1. 模型注册
    NODE_IPs = ["223.2.39.61"]
    FastModelAPI.register(NODE_IPs)
    # 2.模型初始化
    FastModelAPI.initialize_model("ChinaPyHeff")
    # 3.调用模型
    params = {
        "model": "ensemble_streamflow_hindcasting.py",
        "parameter": "-gefs_hindcast_bjp huaiheliuyu wangjiaba -gage_info xixian 7 2010061700 -roff XAJ -rout LagK"
    }

    result = FastModelAPI.run_model(params)
    if result:
        print(f"模型调用结果: {result}")

    # 4.下载模型结果
    filer = FastModelAPI.download_results()
